/**Android适配启动页
 * Created by 10691 on 17/5/10.
 */
import React, {Component} from 'react';
import {Image, StyleSheet, Platform, View} from 'react-native';
import {NavigationActions} from 'react-navigation';

import {MainTab} from './Main.js';
import {screenWidth, screenHeight} from '../communals/MyExports.js';

/**
 * 利用reset重置路由表，避免启动页可回退
 */
const resetAction = NavigationActions.reset({
    index: 0,
    actions: [
        NavigationActions.navigate({routeName: 'MainTab'})
    ]
});

export default class LaunchPage extends Component {

    /**
     * 组件加载完成
     */
    componentDidMount() {
        // 设置延时1.5s跳转
        setTimeout(() => {
            this.props.navigation.dispatch(resetAction)
        }, Platform.OS === 'ios' ? 0 : 1500);
    }

    render() {
        return (
            // 启动页
            <View>
                <Image source={{uri: 'launch_image'}} style={LaunchPageStyles.imageStyle}/>
            </View>
        )
    }
}

const LaunchPageStyles = StyleSheet.create({
    imageStyle: {
        width: screenWidth,
        height: screenHeight,
    }
});

